package com.shuzixiangcun.service.front;

import com.shuzixiangcun.dao.EnterpriseCertificationDao;
import com.shuzixiangcun.entity.EnterpriseCertification;
import com.shuzixiangcun.utils.UploadUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 企业认证信息表(EnterpriseCertification)表服务实现类
 *
 * @author makejava
 * @since 2024-06-24 10:38:14
 */
@Service
public class EnterpriseCertificationFServiceImpl {
    @Resource
    private EnterpriseCertificationDao enterpriseCertificationDao;

    @Autowired
    private UploadUtil uploadUtil;

    /**
     * 文件上传接口
     * @param file
     * @return
     */
    public ResponseEntity upLoadFiles(String savePath,MultipartFile file, HttpServletRequest request) {
        String filePath =  uploadUtil.upLoadFiles(savePath,file,request);
        return ResponseEntity.ok(filePath);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */

    public EnterpriseCertification queryById(Integer id) {
        return this.enterpriseCertificationDao.queryById(id);
    }



    /**
     * 新增数据
     *
     * @param enterpriseCertification 实例对象
     * @return 实例对象
     */

    public EnterpriseCertification insert(EnterpriseCertification enterpriseCertification) {
        this.enterpriseCertificationDao.insert(enterpriseCertification);
        return enterpriseCertification;
    }

    /**
     * 修改数据
     *
     * @param enterpriseCertification 实例对象
     * @return 实例对象
     */

    public EnterpriseCertification update(EnterpriseCertification enterpriseCertification) {
        this.enterpriseCertificationDao.update(enterpriseCertification);
        return this.queryById(enterpriseCertification.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */

    public boolean deleteById(Integer id) {
        return this.enterpriseCertificationDao.deleteById(id) > 0;
    }
}
